<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="http://www.baidu.com/">
        <span>账号</span><input type="text" id="username">
        <span>密码</span><input type="text" id="password">
        <input type="submit" value="提交" id="submit">
    </form>
    <script>
        var username = document.querySelector('#username')
        var password = document.querySelector('#password')
        var submit = document.querySelector('#submit')
        submit.onclick = function(){
            console.log(password.value.length)
            if(password.value.length<6){
                alert('密码最少6位')
                return false
            }
        }
        
    </script>
</body>
</html>